package book.controller;

import book.entity.role;
import book.service.RolePrivilegesService;
import book.service.RoleServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.lang.reflect.MalformedParameterizedTypeException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/role")
public class RolePrivilegesController {

    @Autowired
    RoleServices roleServices;

    @RequestMapping("/index")
    public String getAll(){ return "role/list";}

    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object>  list(){
        Map<String,Object> map=new HashMap<>();
        List<role> r=roleServices.getAll();
        int shu=roleServices.getCount();
        System.out.println(r.get(1).getName()+"  "+shu);
        map.put("total",shu);
        map.put("rows",r);
        return map;
    }


}
